package com.zhijian.warehouse.manage.dao;

import com.zhijian.warehouse.manage.entity.export.StoreExport;
import com.zhijian.warehouse.manage.entity.po.Store;
import com.zhijian.warehouse.manage.entity.vo.request.StoreSearchVo;
import com.zhijian.warehouse.manage.entity.vo.request.StoreWarehouseLocationSearchVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreVo;
import com.zhijian.warehouse.manage.entity.vo.response.StoreWarehouseLocationProjectVo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface StoreMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Store record);

    int insertSelective(Store record);

    Store selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Store record);

    int updateByPrimaryKey(Store record);

    /**
     * 查询总数
     *
     * @param storeSearchVo
     * @return
     */
    int count(StoreSearchVo storeSearchVo);

    /**
     * 查询列表
     *
     * @param storeSearchVo
     * @return
     */
    List<StoreVo> selectList(StoreSearchVo storeSearchVo);

    /**
     * 查询单个
     *
     * @param storeSearchVo
     * @return
     */
    StoreVo selectOne(StoreSearchVo storeSearchVo);

    /**
     * 根据ID查询vo
     *
     * @param id
     * @return
     */
    StoreVo selectVoById(Long id);

    /**
     * 批量删除
     *
     * @param idList
     * @return
     */
    void deleteByIdList(@Param("idList") List<Long> idList);

    /**
     * 动态删除
     *
     * @param storeSearchVo
     * @return
     */
    void deleteByCondition(StoreSearchVo storeSearchVo);

    /**
     * 批量新增
     *
     * @param entities
     * @return
     */
    int insertBatch(@Param("entities") List<Store> entities);

    /**
     * 根据ProductId查询列表
     *
     * @param productId
     * @return
     */
    List<StoreVo> selectListByProductId(Long productId);

    /**
     * 根据WarehouseId查询列表
     *
     * @param warehouseId
     * @return
     */
    List<StoreVo> selectListByWarehouseId(Long warehouseId);

    /**
     * 根据CreateUserId查询列表
     *
     * @param createUserId
     * @return
     */
    List<StoreVo> selectListByCreateUserId(Long createUserId);

    /**
     * 查询库存
     * @param warehouseLocationIds 库位id
     * @param warehouseId  仓库id
     * @return
     */
    List<Store> selectByCommodityIds(@Param("warehouseLocationIds") List<Long> warehouseLocationIds,@Param("productIds") List<Long> productIds,
                                         @Param("warehouseId") Long warehouseId);

    /**
     * 批量更新库存
     * @param stockUpdates
     * @return
     */
    int batchUpdate(@Param("list") List<Store> stockUpdates);

    /**
     * 导出库存列表
     * @param param
     * @return
     */
    List<StoreExport> selectStoreExportList(StoreSearchVo param);

    /**
     * 刷新库存开始日期
     */
    void flushStartDay();

    /**
     * 刷新库存结束日期
     */
    void flushStoreEnd();

    /**
     * 查询库位项目列表
     * @param storeSearchVo
     * @return
     */
    int selectWarehouseLocationProjectCount(StoreWarehouseLocationSearchVo storeSearchVo);

    /**
     * 查询库位项目列表
     * @param storeSearchVo
     * @return
     */
    List<StoreWarehouseLocationProjectVo> selectWarehouseLocationProjectList(StoreWarehouseLocationSearchVo storeSearchVo);

    /**
     * 根据productId查询仓库id
     * @param productId
     * @return
     */
    List<Long> selectWarehouseId(@Param("productId") Long productId);
}
